package com.goldplusgold.tradedelay.app.base.widget;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.goldplusgold.tradedelay.app.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * Created by Administrator on 2017/2/28.
 */

public class TDSureOrderDialog extends Dialog {

    @BindView(R.id.type_txt)
    TextView typeTxt;
    @BindView(R.id.way_txt)
    TextView wayTxt;
    @BindView(R.id.price_txt)
    TextView priceTxt;
    @BindView(R.id.quantity_txt)
    TextView quantityTxt;
    @BindView(R.id.btn_cancle)
    Button btnCancle;
    @BindView(R.id.btn_sure)
    Button btnSure;
    private OnSureListener SureListener;
    private LayoutInflater mLayoutInflater;
    private View rootView;
    private String mTradeType;
    private String mTotalPrice;
    private String mVolume;
    private String mTradeWay;

    public TDSureOrderDialog(Context context, String tradeType, String tradeWay, String totalPrice, String volume, int themeResId) {
        super(context, themeResId);
        this.mTradeType = tradeType;
        this.mTotalPrice = totalPrice;
        this.mVolume = volume;
        this.mTradeWay = tradeWay;
        mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        initViews();
    }

    private void initViews() {
        rootView = mLayoutInflater.inflate(R.layout.dialog_order_sure, null);
        setContentView(rootView);
        ButterKnife.bind(this);
        typeTxt.setText("种类 : " + mTradeType);
        priceTxt.setText("价格 : " + mTotalPrice + "元");
        wayTxt.setText("类型 : " + mTradeWay);
        quantityTxt.setText("手数 : " + mVolume + "手");
    }

    @OnClick({R.id.btn_cancle, R.id.btn_sure})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_cancle:
                dismiss();

                break;
            case R.id.btn_sure:
                SureListener.sure();
                dismiss();
                break;
        }
    }

    public void setOnSureListener(OnSureListener sureListener) {
        SureListener = sureListener;
    }

    public interface OnSureListener {
        void sure();
    }
}
